﻿namespace EFS.RC.CommunicatorContext.Operators
{
	public partial class SupervisorControls : EFS.RC.CommunicatorContext.Operators.Controls
	{
		#region EventHandlers
		/// Event used when a message has been received
		public event System.EventHandler<EFS.RC.CommunicatorContext.Operators.CustomerSurvey.RequestCustomerSurveyArgs> RequestCustomerSurvey;
		#endregion

		public SupervisorControls()
		{
			InitializeComponent();

			// ignore in design tool
			if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
			{
				UpdateUI();

				controlCustomerSurvey.RequestCustomerSurvey += controlCustomerSurvey_RequestCustomerSurvey;
			}
		}

		#region Properties
		/// Property ButtonHold: Get
		protected override System.Windows.Controls.Button ButtonHold
		{
			get
			{
				return buttonHold;
			}
		}

		/// Property ButtonResume: Get
		protected override System.Windows.Controls.Button ButtonResume
		{
			get
			{
				return buttonResume;
			}
		}
		#endregion

		#region Utilities
		/// Update buttons
		public override void UpdateInfo(EFS.RC.CC.Messages.Communicator.Lync.Conversation.Info conversationInfo)
		{
			// call base
			base.UpdateInfo(conversationInfo);

			// clear first
			buttonMonitor.IsEnabled = conversationInfo.Monitoring != EFS.RC.CC.Messages.Communicator.Lync.Conversation.Info.MonitoringStatus.SupervisorListening;
			buttonWhisper.IsEnabled = conversationInfo.Monitoring != EFS.RC.CC.Messages.Communicator.Lync.Conversation.Info.MonitoringStatus.SupervisorWhispering;
			buttonBargeIn.IsEnabled = conversationInfo.Monitoring != EFS.RC.CC.Messages.Communicator.Lync.Conversation.Info.MonitoringStatus.SupervisorBargedIn;
		}
		#endregion

		#region UI
		/// UpdateUI
		private void UpdateUI()
		{
		}
		#endregion

		#region LoadData
		/// LoadParticipants
		public void LoadParticipants(EFS.RC.CC.Messages.Communicator.Lync.Participant.StatusList statusList)
		{
			dataGridParticipants.ItemsSource = statusList;				
		}
		#endregion

		#region ControlEvents
		/// buttonMonitor_Click
		private void buttonMonitor_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			HandleButtonClicked(sender, new ButtonsEventArgs(ButtonType.Monitor));
		}

		/// buttonWhisper_Click
		private void buttonWhisper_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			HandleButtonClicked(sender, new ButtonsEventArgs(ButtonType.Whisper));
		}

		/// buttonBargeIn_Click
		private void buttonBargeIn_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			HandleButtonClicked(sender, new ButtonsEventArgs(ButtonType.BargeIn));
		}

		/// dataGridParticipants_SelectionChanged
		private void dataGridParticipants_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
		{
			//UpdateTabControlsButtons();
		}

		/// buttonScore_Click
		private void buttonScore_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			// open score in new browser
			EFS.RC.CommunicatorContext.Common.Functions.StartSurveyListExternal(ConversationGuid, EFS.RC.CC.CH.Entities.Surveys.SurveyInfo.eReviewType.Agent);
		}

		/// controlCustomerSurvey_RequestCustomerSurvey
		private void controlCustomerSurvey_RequestCustomerSurvey(object sender, EFS.RC.CommunicatorContext.Operators.CustomerSurvey.RequestCustomerSurveyArgs e)
		{
			if (null != RequestCustomerSurvey)
			{
				this.RequestCustomerSurvey(sender, e);
			}
		}
		#endregion
	}

}